package lifeimprint.BluetoothSample;

import java.util.StringTokenizer;

import android.os.Bundle;
import android.util.Log;


public class HandlingGPS {
	private String gpsinfo;
	private String filterinfo;
	private Bundle mybundle;
	
    public HandlingGPS(String s){
    	gpsinfo=s;
    }
    
    public HandlingGPS(String s,String y){
    	gpsinfo=s;
    	filterinfo=y;
    	//Log.d("mydebug",s);
    }
    
    public Bundle outputgps(){
    	Handlinginfo();
    	return mybundle;
    }
    
    private void Handlinginfo(){
    	int i=0;
    	mybundle=new Bundle();
    	
    	//if (gpsinfo.indexOf("$")==0){
			if(gpsinfo.substring(0, 6).equals(filterinfo)){
				StringTokenizer str=new StringTokenizer(gpsinfo,",");
				while(str.hasMoreTokens()){
                    switch(i){
                    case 0:
                    	i++;
                    	mybundle.putString("0", str.nextToken());
                    	break;
                    case 1:
                    	i++;
                    	mybundle.putString("1", str.nextToken());
                    	break;
                    case 2:
                    	i++;
                    	mybundle.putString("2", str.nextToken());
                    	break;
                    case 3:
                    	i++;
                    	mybundle.putString("3", str.nextToken());
                    	break;
                    case 4:
                    	i++;
                    	mybundle.putString("4", str.nextToken());
                    	break;
                    case 5:
                    	i++;
                    	mybundle.putString("5", str.nextToken());
                    	break;
                    case 6:
                    	i++;
                    	mybundle.putString("6", str.nextToken());
                    	break;
                    case 7:
                    	i++;
                    	mybundle.putString("7", str.nextToken());
                    	break;
                    case 8:
                    	i++;
                    	mybundle.putString("8", str.nextToken());
                    	break;
                    case 9:
                    	i++;
                    	mybundle.putString("9", str.nextToken());
                    	break;
                    case 10:
                    	i++;
                    	mybundle.putString("10", str.nextToken());
                    	break;
                    case 11:
                    	i++;
                    	mybundle.putString("11", str.nextToken());
                    	break;
                    case 12:
                    	i++;
                    	mybundle.putString("12", str.nextToken());
                    	break;
                    case 13:
                    	i++;
                    	mybundle.putString("13", str.nextToken());
                    	break;
                    case 14:
                    	i++;
                    	mybundle.putString("14", str.nextToken());
                    	break;
                    }
				}
				
			}
			
		}
    	
    
    
}
